package com.faradel.pharmapp.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.faradel.pharmapp.entities.MedicationInventory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.faradel.pharmapp.dao.MedicationInventoryDAO;

@Repository("medicationInventoryServiceImpl")
public class MedicationInventoryServiceImpl implements MedicationInventoryServiceInterface
{
    @Resource
    MedicationInventoryDAO medicationInventoryDaoImpl;

    @Override
    @Transactional(readOnly = false)
    public void addMedicationInventory(MedicationInventory medication)
    {
        medicationInventoryDaoImpl.save(medication);
    }

    @Override
    @Transactional(readOnly = false)
    public void updateMedicationInventory(MedicationInventory medication)
    {
        medicationInventoryDaoImpl.update(medication);
    }

    @Override
    @Transactional(readOnly = false)
    public void deleteMedicationInventory(MedicationInventory medication)
    {
        medicationInventoryDaoImpl.delete(medication);
    }

    @Override
    @Transactional(readOnly = true)
    public MedicationInventory getMedicationInventoryById(int id)
    {
        return medicationInventoryDaoImpl.get(id);
    }

    @Override
    @Transactional(readOnly = true)
    public List<MedicationInventory> getAllMedicationInventory()
    {
        return medicationInventoryDaoImpl.selectAll();
    }

    @Override
    @Transactional(readOnly = true)
    public List<MedicationInventory> getMedicationInventoryByColumns(Map<String, String> map)
    {
        return medicationInventoryDaoImpl.findByColumn(map);
    }

    @Override
    @Transactional(readOnly = true)
    public List<MedicationInventory> getLowInventory()
    {
        return medicationInventoryDaoImpl.getLowInventory();
    }

}
